<?php
namespace app\admin\model;
use think\Db;
use think\Model;

class BusHotAreaModel extends Model
{
	public function __construct()
    {
        parent::__construct();

    }

    public function getHotAreaList($page,$limit,$map=array(),$field = 'a.*'){
    	return Db::name('bus_hot_area a')->join('region b','b.region_id=a.region_id','LEFT')
            ->page($page,$limit)->where($map)->field($field)->order('ordinal asc,hot_id desc')->select();
    }

    public function getHotAreaById($hot_id,$field='a.*')
    {
        return Db::name("bus_hot_area a")->join('__REGION__ b','b.region_id=a.region_id','LEFT')
            ->join('__ADMIN__ c','c.admin_id=a.admin_id','LEFT')
            ->field($field)->where(array('hot_id'=>$hot_id))->find();
    }

    public function getRegion($map=array(),$field = '*')
    {
        return Db::name('region')->where($map)->field($field)->select();
    }

    public function createHotArea($data)
    {
        return Db::name('bus_hot_area')->insertGetId($data);
    }

    public function updateHotArea($map,$data)
    {
        return Db::name('bus_hot_area')->where($map)->update($data);
    }

}
